package cn.terminus.data.customer.customleaseinfo.impl;

import cn.terminus.common.customer.bean.customleaseinfo.dto.*;
import cn.terminus.data.customer.customleaseinfo.dao.CustomLeaseInfoDao;
import cn.terminus.data.customer.customleaseinfo.mapper.CustomLeaseInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomLeaseInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:56
 */
@Repository
public class CustomLeaseInfoDaoImpl implements CustomLeaseInfoDao {
    @Resource
    private CustomLeaseInfoMapper customLeaseInfoMapper;

    @Override
    public Integer add(CustomLeaseInfoNewDto dto) {
        return customLeaseInfoMapper.add(dto);
    }

    @Override
    public Integer update(CustomLeaseInfoNewDto dto) {
        return customLeaseInfoMapper.update(dto);
    }

    @Override
    public List<CustomLeaseInfoResultDto> gets(CustomLeaseInfoGetsDto dto) {
        return customLeaseInfoMapper.gets(dto);
    }

    @Override
    public List<CustomLeaseInfoResultDto> query(CustomLeaseInfoQueryDto dto) {
        return customLeaseInfoMapper.query(dto);
    }

    @Override
    public Integer delete(CustomLeaseInfoDeleteDto dto) {
        return customLeaseInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomLeaseInfoResultDto> page(CustomLeaseInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomLeaseInfoResultDto> result = (Page<CustomLeaseInfoResultDto>) customLeaseInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomLeaseInfoResultDto.class), page, result.getTotal());
    }
}
